package org.example;

import javax.swing.*;
import java.awt.*;

public class Frame1 extends JFrame {
    private Container contentP; //内容面板

    private JButton Guess;

    private JButton Cancel;

    private JLabel label;

    private JTextField nameTxt;

    private JLabel image;

    private JMenuBar menuBar;


    public Frame1() {
        this.setSize(500, 500);
        this.setLocationRelativeTo(null);
        this.setTitle("Let's Play Hilo");
        this.setResizable(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        this.addContent();

        this.setVisible(true);
    }

    private void addContent() {
        this.contentP = this.getContentPane();//获取窗体的内容面板
        this.contentP.setLayout(null);//设置空布局，即采用绝对定位的方式
        this.contentP.setBackground(Color.gray);//设置内容面板背景色

        this.menuBar = new JMenuBar();
        this.menuBar.setBounds(0, 0, 500, 50);
        this.contentP.add(this.menuBar);

        this.label = new JLabel();
        this.label.setText("50 is");
        this.label.setBounds(200, 100, 100, 100);
        this.contentP.add(this.label);

        this.image = new JLabel();
        ImageIcon image = new ImageIcon("/Users/cengyunke/Desktop/atm1/GUIWork/src/main/java/org/example/img/pexels-artem-beliaikin-853199.jpg");
        ImageIcon newImage = new ImageIcon(image.getImage().getScaledInstance(88, 86, Image.SCALE_DEFAULT));
        this.image.setIcon(newImage);
        this.image.setBounds(250, 100, 88, 86);
        this.contentP.add(this.image);

        this.nameTxt = new JTextField();
        this.nameTxt.setBounds(150, 200, 200, 50);
        this.contentP.add(this.nameTxt);


        this.Guess = new JButton("Guess");
        this.Guess.setBounds(100, 330, 80, 60);
        this.contentP.add(this.Guess);

        this.Cancel = new JButton("Cancel");
        this.Cancel.setBounds(300, 330, 80, 60);
        this.contentP.add(this.Cancel);

    }
}
